<template>
  <div class="readme-layout clearfix" :style="readmeResult.readmeBImg">
    <div class="readme-left fl">
      <div class="readme-txt">
        <h2>三位一体快速落地平台</h2>
        <div class="readme-actor">只为这样你: 可配置化管理</div>
        <p>一套为三位一体准备的基于可配置化组件库，提供了专业配置，帮助你的城市快速落地。</p>
      </div>
    </div>
    <div class="readme-right fl">
      <div class="read-img">
        <img :src="readmeResult.readmeImg">
      </div>
    </div>
  </div>
</template>
<script>
  import { mapState } from 'vuex'

  export default {
    data () {
      return {
        loginId: JSON.parse(sessionStorage.getItem('loginId'))
      }
    },
    computed: {
      ...mapState('readme', ['readmeResult'])
    },
    created () {
      // 第一步：获取dataId
      this.getInitInfor()
    },
    methods: {
      // 获取用户前置配置信息及dataId
      getInitInfor () {
        let url = this.api.init.getInitInfor
        let params = {
          userId: this.loginId
        }
        this.$axios.get(url, {params: params}).then((res) => {
          if (res.data.msg.code === '20000') {
            if (res.data.data) {
              let initData = res.data.data
              sessionStorage.setItem('dataId', JSON.stringify(initData.id))
              sessionStorage.setItem('initData', JSON.stringify(initData))
              sessionStorage.setItem('appId', JSON.stringify(initData.appId))
            } else {
              this.$Modal.confirm({
                title: '提示',
                content: '请先配置前置条件信息',
                onOk: () => {
                  this.$router.push('/initialization')
                },
                onCancel: () => {
                  this.$Message.info('点击了取消')
                }
              })
            }
          } else {
            this.$Message.error({content: res.data.msg.message, duration: 5})
          }
        }).catch((err) => {
          if (err) throw err
          this.$Message.error({content: '网络异常', duration: 5})
        })
      }
    }
  }
</script>
